const address = {
  // local: 'wss://localhost:8443/intercom',
  // local: 'wss://192.168.3.106:8443/intercom',
  local: 'wss://localhost:8443/intercom',
  // local: 'wss://192.168.3.106:8443/intercom',
  serve: 'wss://39.103.237.231:8443/intercom'
}

const userA = {
  userId: 'user-id-a-a-a',
  username: 'a-a-a-name',
}
const userB = {
  userId: 'user-id-b-b-b',
  username: 'b-b-b-name',
}

const classroom = {
  classId: 'classId-001',
  classname: 'classname-001',
}

function useSocket(user, cb) {
  const socket = io(address.local, {
    reconnectionDelayMax: 10000,
    transports: ["websocket"],
    query: Object.assign({}, user, classroom),
  })

  socket.on('connect', () => {
    console.log('connect')

    setTimeout(() => {
      socket.emit('login', { members: [userA, userB], rooms: [classroom] }, () => {
        console.log(io)
      })

      cb && cb()
    }, 500)
  })

  return socket
}

